import os


class Direcotry:
    def __init__(self, path: str):
        self._path = path

    def get_files(self, pattern=None):
        """
        获取目录下所有文件。
        pattern: 搜索指定规则的名字，如果为None则是全部。
        """
        files = []
        path = self._path
        _files = os.listdir(path)
        if path[-1] != r'/' or path[-1] != '\\':
            if '/' in path:
                path += '/'
            elif '\\' in path:
                path += '\\'
        for f in _files:
            if os.path.isfile(path + f):
                if pattern is not None:
                    if pattern in f:
                        files.append(path + f)
                else:
                    files.append(path + f)

        return files


if __name__ == '__main__':
    d = Direcotry(r'D:\工作\CC\01-巡检')
    f = d.get_files(pattern='zabbix2020')
    for _ in f:
        print(_)